import {deepClone} from "../../../utils/index";
import RenderUtils from "../RenderUtils";
import {RenderTypeItem} from "../ConfigType";

const timePicker: RenderTypeItem = {
  name: 'timePicker',
  /**
   *
   * @param createElement
   * @param vm
   * @param formItem
   * @return {VNode[]}
   */
  render(createElement, vm, formItem) {
    let tag = 'el-time-picker'
    if (formItem?.props?.type === 'timeSelect') {
      tag = 'el-time-select'
    }
    const props = deepClone(formItem.props)
    delete props.type
    const config = RenderUtils.getConfig(vm, formItem, {
      props: {
        placeholder: '请选择',
        ...props,
      },
    }, this)
    return [
      createElement(tag, config)
    ]
  }
}

export default timePicker
